/**
 * Created by sunkejun on 2015/10/15.
 */

$(document).ready(function(){
    fileManger.init();
})

var fileManger  = (function ($) {
    //...
    return {
        init:function(){
            $('#fileupload').fileupload({
                    url: '/admin/file/uploadfile',
                    // Enable image resizing, except for Android and Opera,
                    // which actually support image resizing, but fail to
                    // send Blob objects via XHR requests:
                    disableImageResize: /Android(?!.*Chrome)|Opera/
                    .test(window.navigator.userAgent),
                    maxFileSize: 29999000,
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png|txt|xls|sql|doc|docx|xlsx|ppt|html|rar|mp3|mpg4|wmv|pdf|flv])$/i
            });
        },
        openUpload:function(){
            $("#file_up_modal").modal('show');
        },
        close: function () {

            $("#file_up_modal").modal('hide');
            window.location.reload();
        },
        reflash: function () {
            window.location.reload();
        },
        viewUrl:function(url){
            swal({
                title:language.getNorlanguage().filemanage_title,
                text: "<span style='color:#F8BB86'>"+url+"<span>",
                html: true , confirmButtonText: language.getNorlanguage().delete_sub,
                }
            );
        },
        downSource:function(){

        },
        deleteFile:function(id){
            swal({
                title: language.getNorlanguage().delete_title,
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: language.getNorlanguage().delete_sub,
                cancelButtonText: language.getNorlanguage().delete_cancle,
                closeOnConfirm: true,
                html: false
            }, function(){
                ComdataUtil.ajaxpostnormal('/admin/filemanage/'+id,{},function(data){
                    window.location.reload();
                },"DELETE");
            });
        }
    }
})(jQuery);